module game{
    export class GameResultView extends BaseEuiView{
        public btn_challenge:eui.Button;
        public btn_showOff:eui.Button;

        public btn_start:eui.Group;

        public txt_score:eui.Label;
        public txt_history:eui.Label;

        public start:eui.Image;
        
        public constructor($m:BaseController,$parent:eui.Group){
            super($m,$parent);
            this.skinName = "resource/skin/GameResult.exml";
        }

        public initUI():void{
            super.initUI();

            this.btn_challenge.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClickHandler,this);
            this.btn_showOff.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClickHandler,this);
            this.btn_start.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClickHandler,this);
            this.start.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onClickHandler,this);

            this.skin.width = egret.MainContext.instance.stage.stageWidth;
            this.skin.height = egret.MainContext.instance.stage.stageHeight;
        }

        public open(...param:any[]):void {
            super.open(...param);
            this.txt_score.text = gameData.curmax +"";
            this.txt_history.text = "历史最高分:"+gameData.historyScore ;

            //离屏画布

            //清空保存数据
            gameData.reset();
            gameData.saveWXData();
        }

        public onClickHandler(e:egret.TouchEvent){
            switch(e.currentTarget){
                case this.btn_challenge:
                break;
                case this.btn_showOff:
                break;
                case this.btn_start:
                    App.ViewManager.close(ViewConst.Core);
                    App.ViewManager.close(ViewConst.GameResult);
                    App.ViewManager.open(ViewConst.Home);
                break;
                // case this.start:
                //     App.ViewManager.close(ViewConst.Core);
                //     App.ViewManager.close(ViewConst.GameResult);
                //     App.ViewManager.open(ViewConst.Home);
                // break;
            }
        }




    }
}